/**
 * @date 2005-12-10 20:31:14
 *
 */
package org.nanhill.support.spring.mvc;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.view.AbstractView;

/**
 * Convenient superclass for Excel document views.
 * 
 * @author alin
 */
public abstract class AbstractExcelView extends AbstractView {

	/** The content type for an Excel response */
	private static final String CONTENT_TYPE = "application/vnd.ms-excel";

	/**
	 * Default Constructor. Sets the content type of the view to
	 * "application/vnd.ms-excel".
	 */
	public AbstractExcelView() {
		setContentType(CONTENT_TYPE);
	}

	/**
	 * Subclasses must implement this method to create an Excel HSSFWorkbook
	 * document, given the model.
	 * 
	 * @param model
	 *            the model Map
	 * @param request
	 *            in case we need locale etc. Shouldn't look at attributes.
	 * @param response
	 *            in case we need to set cookies. Shouldn't write to it.
	 */
	protected abstract void buildExcelDocument(Map model,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception;

}
